package com.example.demo.commen;

import lombok.Data;

@Data
public class AppResult<T>{

    public int code;      //业务性状态码

    public String message;

    public T data;


    public  static AppResult success(){
        AppResult appResult = new AppResult();
       appResult.setCode(ResultCode.SUCCESS.code);
        appResult.setMessage("成功");
        appResult.setData("");
        return appResult;
    }

    public static AppResult success(String message){
        AppResult appResult = new AppResult();
        appResult.setCode(200);
        appResult.setMessage("成功");
        appResult.setData("");
        return appResult;
    }

    public  static <T>AppResult<T> success(T data){
        AppResult appResult = new AppResult();
        appResult.setCode(200);
        appResult.setMessage("成功");
        appResult.setData(data);
        return appResult;
    }

    public static AppResult failed(){
        AppResult appResult = new AppResult();
        appResult.setCode(1000);
        appResult.setMessage("失败");
        appResult.setData("");
        return appResult;
    }

    public static AppResult failed(String message){
        AppResult appResult = new AppResult();
        appResult.setCode(1000);
        appResult.setMessage(message);
        appResult.setData("");
        return  appResult;
    }

    public static <T>AppResult<T> failed(T data){
        AppResult appResult = new AppResult();
        appResult.setCode(1000);
        appResult.setMessage("失败");
        appResult.setData(data);
        return  appResult;
    }

}
